﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Media.Animation;

namespace Mosiac_Desktop
{
    /// <summary>
    /// Interaction logic for WindowFlash.xaml
    /// </summary>
    public partial class WindowFlash : Window
    {
        private DispatcherTimer oTimer;
        public WindowFlash()
        {
            InitializeComponent();
            this.Focus();
            oTimer = new DispatcherTimer();
            oTimer.Interval = new TimeSpan(0, 0, 3);
            oTimer.Tick += new EventHandler(oTimer_Tick);
            oTimer.Start();
            this.Topmost = true;
            Storyboard storyboard = new Storyboard();
            TimeSpan duration = new TimeSpan(0, 0, 1);

            DoubleAnimation animation = new DoubleAnimation();

            animation.From = 0.0;
            animation.To = 1.0;
            animation.Duration = new Duration(duration);

            Storyboard.SetTargetName(animation, this.image_wallpaper.Name);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
            storyboard.Children.Add(animation);

            storyboard.Begin(this);
        }
        void oTimer_Tick(object sender, EventArgs e)
        {
            Storyboard storyboard = new Storyboard();
            TimeSpan duration = new TimeSpan(0, 0, 1);

            DoubleAnimation animation = new DoubleAnimation();

            animation.From = 1.0;
            animation.To = 0.0;
            animation.Duration = new Duration(duration);
 
            Storyboard.SetTargetName(animation, this.image_wallpaper.Name);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));

            storyboard.Children.Add(animation);

            storyboard.Completed += new EventHandler(storyboard_Completed);

            storyboard.Begin(this);

        }

        void storyboard_Completed(object sender, EventArgs e)
        {
            Close();
        }
    }

}